package com.ruoyi.web.hbxx.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.hb.service.IChannelBuoyService;
import com.ruoyi.web.hbxx.domain.ChannelBuoyInfo;
import com.ruoyi.web.hbxx.domain.ChannelBuoyInfoLog;
import com.ruoyi.web.hbxx.service.IChannelBuoyInfoLogService;
import com.ruoyi.web.hbxx.service.IChannelBuoyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 南方测绘航标数据Controller
 *
 * @author ruoyi
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/system/channelBuoyLog")
public class ChannelBuoyInfoLogController extends BaseController
{
    @Autowired
    private IChannelBuoyInfoLogService channelBuoyInfoLogService;

    /**
     * 查询南方测绘航标数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChannelBuoyInfoLog channelBuoyInfoLog) throws IOException {
        startPage();
        List<ChannelBuoyInfoLog> list = channelBuoyInfoLogService.selectChannelBuoyInfoLogList(channelBuoyInfoLog);
        return getDataTable(list);
    }

    /**
     * 导出南方测绘航标数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:export')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChannelBuoyInfoLog channelBuoyInfoLog)
    {
        List<ChannelBuoyInfoLog> list = channelBuoyInfoLogService.selectChannelBuoyInfoLogList(channelBuoyInfoLog);
        ExcelUtil<ChannelBuoyInfoLog> util = new ExcelUtil<ChannelBuoyInfoLog>(ChannelBuoyInfoLog.class);
        util.exportExcel(response, list, "南方测绘航标数据数据");
    }

    /**
     * 获取南方测绘航标数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(channelBuoyInfoLogService.selectChannelBuoyInfoLogById(id));
    }

    /**
     * 新增南方测绘航标数据
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:add')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChannelBuoyInfoLog channelBuoyInfoLog)
    {
        return toAjax(channelBuoyInfoLogService.insertChannelBuoyInfoLog(channelBuoyInfoLog));
    }

    /**
     * 修改南方测绘航标数据
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:edit')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChannelBuoyInfoLog channelBuoyInfoLog)
    {
        return toAjax(channelBuoyInfoLogService.updateChannelBuoyInfoLog(channelBuoyInfoLog));
    }

    /**
     * 删除南方测绘航标数据
     */
    @PreAuthorize("@ss.hasPermi('system:channelBuoy:remove')")
    @Log(title = "南方测绘航标数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(channelBuoyInfoLogService.deleteChannelBuoyInfoLogByIds(ids));
    }
}
